﻿@using Fap.AspNetCore.Controls
@model Fap.AspNetCore.ViewModel.JsTreeViewModel
@{
    Layout = null;
    string frmCols=Model.TempData["frmCols"];
}
    <script>
    function GetRefResult() {
        var ref = $('#tree-@Model.CtrlName').jstree(true),
                        sel = ref.get_selected();

        if (!sel.length) { return false; }
        sel = sel[0];
        if (ref.get_node(sel).data.selectable == false)
        {
            bootbox.alert("你没有权限选择此项！");
            return;
        }
        var ext = "";
        debugger
        if (ref.get_node(sel).data!=null&&ref.get_node(sel).data.ext != undefined)
        {
            ext = ref.get_node(sel).data.ext;
        }
        var code = sel;
        var name = ref.get_text(sel);
        var result = { "code": code, "name": name,"ext":ext,"frmcols":'@frmCols' };
        return result;
    }
    function GetRefResults() {
        var ref = $('#tree-@Model.CtrlName').jstree(true),
            checks = ref.get_checked();
        var result = [];
        $.each(checks, function (i, d) {
            let name = ref.get_text(d);
            if (ref.get_node(d).data != null && ref.get_node(d).data.ext != undefined) {
                ext = ref.get_node(d).data.ext;
            }
            result.push({ "code": d, "name": name,"ext":ext,"frmcols":'@frmCols' });
        });        
        return result;
    }
    </script>


<div class="row">
    <div class="col-xs-12 treeScrollable">
        <fap-tree id="@Model.CtrlName" is-async="false" plugin-checkbox="@Model.IsMulti" json-data="@Model.JsonData" plugin-dnd="false" > </fap-tree>
    </div>
</div>

